'use strict';

var db = require('../model/db.js');
let date = require('date-and-time');

module.exports = (req,res)=>{
    var _id = req.body._id;
    var content = req.body.content;

    let now = new Date();
    let strNow = date.format(now, 'YYYY/MM/DD HH:mm:ss');
    // console.log(objectId)
    db.update('list',{
        filter:{
            _id : _id,
        },
        update :{
            content : content,
            updateTime : strNow
        },
        callback:(err,result)=>{
            if(err){
                res.json(err);
                return;;
            }
            db.find('list',{
                filter : {
                    _id : _id,
                },
                callback:(err,result)=>{
                    if(err){
                        res.json(err);
                        return;
                    }
                    res.json(result);
                }
            });
        }
    });
}